<?php
namespace Home\Controller;
use Common\Controller\CommonController;

class JoinController extends CommonController{

	public function index(){
		$join=M('join');

		$Count=$join->count();
		$Page = new \Think\Pager($Count,10);
		$show=$Page->showhtml(); 

		$key=I("key");
		if(!empty($key)){
			$where['name'] = array('like',"%".$key."%");
		}

		$joinList=$join->limit($Page->firstRow.",".$Page->firstRow)->order("id desc")->where($where)->select();

		$this->assign('page',$show);
		$this->assign("list",$joinList);
		$this->display();
	}

	public function apply(){
		$status=I('status');
		$id=I('id');

		$data = array('id'=>$id,'status'=>$status);

		$list=M('join')->data($data)->save();

		if($list){
			$this->ajaxReturn(array('s'=>true,'m'=>'成功加盟'));
		}else{
			$this->ajaxReturn(array('s'=>false));
		}
	}

}